package it.getta.vicinometro.popup;

import com.google.android.maps.GeoPoint;

import it.getta.vicinometro.ActivityCallBack;
import it.getta.vicinometro.R;
import it.getta.vicinometro.popup.WarningPopup.OnPopupClickListener;
import it.getta.vicinometro.utils.Utils;
import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;

public class AlarmPointPopup extends VicinometroPopup {
	
	private GeoPoint mAlarmPoint;

	public AlarmPointPopup(Context context, ActivityCallBack activityCallBack, GeoPoint alarmPoint) {
		super(context, activityCallBack, R.layout.balloon_popup);
		mAlarmPoint = alarmPoint;
	}
	
	@Override
	public void showPopup() {
		super.showPopup();
		LinearLayout choose1 = (LinearLayout)mPopupRootView.findViewById(R.id.choose1);
		choose1.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Log.d("TAG", "onClick");
				mActivityCallBack.showSetAlarmPopup(mAlarmPoint);
				dismiss();
			}
		});
		
		LinearLayout choose2 = (LinearLayout)mPopupRootView.findViewById(R.id.choose2);
		choose2.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Log.d("TAG", "onClick");
				manageEraseAlarmPoint();
				dismiss();
			}
		});
		showAtLocation(mActivityCallBack.getPopupAnchor(), Gravity.CENTER, 0, Utils.convertDensityPixel(-100, mContext));
//		show(mActivityCallBack.getPopupAnchor());
	}
	
	private void manageEraseAlarmPoint() { 
		mActivityCallBack.showWarningPopup(R.string.warning, R.string.delete_alarm_point_warning, new OnPopupClickListener() {
			
			@Override
			public void onClick() {
				mActivityCallBack.removeAlarmMarker();
				mActivityCallBack.dismissWarningPopup();
				
			}
		}, new OnPopupClickListener() {
			
			@Override
			public void onClick() {
				mActivityCallBack.dismissWarningPopup();
			}
		});
	}

	
}
